Add a button to back to the palette
authorMatthias Clasen <mclasen@redhat.com>
Thu, 9 Feb 2012 02:55:22 +0000 (21:55 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 14 Feb 2012 21:36:59 +0000 (16:36 -0500)
This is just for trying this out; if it is considered good,
it will be moved into GtkColorChooserDialog

tests/testcolorchooser.c

index 63911ae6c355e0c900342b66f039bf89eea65205..5dffae4c75fe9dc87136dedd8eede339b1a72e46 100644 (file)
@@ -30,16 +30,47 @@ dialog_response (GtkDialog *dialog, gint response)
   gtk_main_quit ();
 }
 
+static void
+show_editor_cb (GtkWidget *dialog, GParamSpec *pspec, GtkWidget *button)
+{
+  gboolean show_editor;
+
+  g_object_get (dialog, "show-editor", &show_editor, NULL);
+  gtk_widget_set_visible (button, show_editor);
+}
+
+static void
+go_to_palette (GtkWidget *button, GtkWidget *dialog)
+{
+  g_object_set (dialog, "show-editor", FALSE, NULL);
+}
+
 int
 main (int argc, char *argv[])
 {
   GtkWidget *dialog;
+  GtkWidget *button;
+  GtkWidget *aa;
+  GtkWidget *image;
   gint i;
 
   gtk_init (NULL, NULL);
 
   dialog = gtk_color_chooser_dialog_new ("Select a color", NULL);
 
+  button = gtk_button_new ();
+  image = gtk_image_new_from_icon_name ("view-grid-symbolic", GTK_ICON_SIZE_MENU);
+  gtk_widget_show (image);
+  gtk_container_add (GTK_CONTAINER (button), image);
+  aa = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
+  gtk_container_add (GTK_CONTAINER (aa), button);
+  gtk_widget_set_no_show_all (button, TRUE);
+  gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (aa), button, TRUE);
+  gtk_button_box_set_child_non_homogeneous (GTK_BUTTON_BOX (aa), button, TRUE);
+  gtk_widget_set_tooltip_text (button, "Show color palette");
+  g_signal_connect (dialog, "notify::show-editor", G_CALLBACK (show_editor_cb), button);
+  g_signal_connect (button, "clicked", G_CALLBACK (go_to_palette), dialog);
+
   for (i = 1; i < argc; i++)
     {
       if (g_strcmp0 (argv[i], "--no-alpha") == 0)